# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Rob Til Freedmen <rob.til.freedman@gmail.com>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: tobias <tobias@archlinux.org>

pkgname=hydrogen
pkgver=1.2.2
pkgrel=1
pkgdesc="An advanced drum machine"
arch=(loong64 x86_64)
url="http://www.hydrogen-music.org/"
license=(GPL-2.0-or-later)
groups=(pro-audio)
depends=(
  gcc-libs
  glibc
  hicolor-icon-theme
  qt5-base
  qt5-svg
  qt5-xmlpatterns
)
makedepends=(
  alsa-lib
  cmake
  jack
  ladspa
  libarchive
  liblo
  liblrdf
  libpulse
  libsndfile
  portaudio
  portmidi
  python
  qt5-tools
)
checkdepends=(cppunit)
optdepends=('new-session-manager: for session management')
source=(
  https://github.com/$pkgname-music/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz
)
sha512sums=('bd6b102b14d30a8e2f4ea7e405199bb34f9b7691b57c3f9f3096c9e30c25c158e3bfd40bcfdd2d449bc153b7d3d9717df401f1e7a086e33dc953247870f1dee0')
b2sums=('30d8624078a29a0514aee01d56865e5923f755de02acfddde45a26d6ffbd68cf3c8c774827fe4538b7d03faefaabb9ddcfd9a28bb404c535ad7f6734eb5b1aff')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=None
    -D WANT_DEBUG=OFF
    -D WANT_CPPUNIT=ON
    -D WANT_LRDF=ON
    -D WANT_PORTAUDIO=ON
    -D WANT_PORTMIDI=ON
    -D WANT_PULSEAUDIO=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
  # update translations
  (
    cd $pkgname-$pkgver/data/i18n
    ./updateTranslations.sh
  )
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    alsa-lib libasound.so
    jack libjack.so
    libarchive libarchive.so
    liblo liblo.so
    liblrdf liblrdf.so
    libpulse libpulse.so
    libsndfile libsndfile.so
    portaudio libportaudio.so
    portmidi libportmidi.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{ChangeLog,DEVELOPERS,INSTALL.md,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}

# vim:set ts=2 sw=2 et:
